<template>
  <div class="father">
    <h3>父组件</h3>
    <div class="content">
      <Game>
        <template v-slot="params">
          <ul>
            <li v-for="y in params.youxi" :key="y.id">
              {{ y.name }}
            </li>
          </ul>
        </template>
      </Game>

      <Game>
        <template v-slot="params">
          <ol>
            <li v-for="item in params.youxi" :key="item.id">
              {{ item.name }}
            </li>
          </ol>
        </template>
      </Game>
      <!-- 数据在子那边,但根据数据生成的机构,却由父亲决定 -->
      <Game>
        <template #default="{ youxi }">
          <h3 v-for="g in youxi" :key="g.id">{{ g.name }}</h3>
        </template>
      </Game>
    </div>
    <div class="categoryList">
      <Category title="游戏列表">
        <template #s1>
          <ul>
            <li v-for="g in gs" :key="g.id">{{ g.name }}</li>
          </ul>
        </template>
        <template v-slot:s2>
          <h2>游戏</h2>
        </template>
      </Category>
      <Category title="美食城市"><img :src="imgUrl" alt=""></Category>
      <Category title="影视推荐">
        <video :src="videoUrl" controls autoplay></video>
      </Category>
    </div>
  </div>
</template>

<script setup lang="ts" name="Father">
import Game from './Game.vue'
import Category from './Category.vue'
import { reactive, ref } from 'vue';

let gs = reactive([
  { id: 'asgytdfats01', name: '英雄联盟' },
  { id: 'asgytdfats02', name: '王者农药' },
  { id: 'asgytdfats03', name: '红色警戒' },
  { id: 'asgytdfats04', name: '斗罗大陆' }
])

let imgUrl = ref('https://z1.ax1x.com/2023/11/19/piNxLo4.jpg')
let videoUrl = ref('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4')
</script>

<style scoped>
.father {
  background-color: rgb(165, 164, 164);
  padding: 20px;
  border-radius: 10px;
}

.content {
  display: flex;
  justify-content: space-evenly;
}

img,
video {
  width: 100%;
}

.categoryList {
  margin-top: 20px;
  display: flex;
  justify-content: space-evenly;

}
</style>